package org.eenie.commonlib.ui.bento.components.banner

import android.widget.ImageView
import cn.bingoogolapple.bgabanner.BGABanner
import com.yelp.android.bento.core.Component
import com.yelp.android.bento.core.ComponentViewHolder

class BannerComponent<P: BGABanner.Delegate<ImageView, IBannerData>, T : IBannerData> constructor(private val mPresenter: P?, private var mDatas: ArrayList<T>) : Component() {


    override fun getHolderType(position: Int): Class<out ComponentViewHolder<*, *>> {
        return BannerHolder::class.java
    }

    override fun getItem(position: Int): List<T> {
        return mDatas
    }

    override fun getCount(): Int {
        return 1

    }


    override fun getPresenter(position: Int): P? {
        return mPresenter
    }


    fun setNewData(newDatas: ArrayList<T>) {
        this.mDatas = newDatas
        notifyDataChanged()
    }


    fun appendData(data: T) {
        this.mDatas.add(data)
        notifyDataChanged()
    }


}

